package com.xinqi.modules.exam.student.manager;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xinqi.common.mybatis.data.service.BaseService;
import com.xinqi.modules.exam.student.domain.CourseExamPaperErrorSetEntity;
import com.xinqi.modules.exam.student.dto.req.CourseExamPaperErrorSetQueryDTO;
import com.xinqi.modules.exam.student.dto.rsp.CourseExamPaperErrorSetResultDTO;
import com.xinqi.modules.exam.student.dto.rsp.CourseExamPaperErrorSetStatsDTO;
import com.xinqi.modules.exam.student.enums.PaperErrorSetTypeEnum;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.function.Consumer;

/**
 * 课程测评学生错题集管理层
 *
 * @author: linkai
 * @date: 2023/07/02
 */
public interface CourseExamPaperErrorSetManager extends BaseService<CourseExamPaperErrorSetEntity> {

    /**
     * 自定义分页查询
     */
    Page<CourseExamPaperErrorSetResultDTO> findPage(Page<Object> page, CourseExamPaperErrorSetQueryDTO query);

    /**
     * 自定义列表查询
     */
    List<CourseExamPaperErrorSetResultDTO> findList(CourseExamPaperErrorSetQueryDTO query);

    /**
     * 根据id查询 课程测评学生错题集数据
     */
    CourseExamPaperErrorSetEntity findById(Long id);

    /**
     * 根据id删除 课程测评学生错题集数据
     */
    @Transactional(rollbackFor = Exception.class)
    boolean deleteById(Long id);

    boolean isExist(Long studentId, PaperErrorSetTypeEnum type, Long questionId);

    List<CourseExamPaperErrorSetEntity> findByExamIdAndStudentId(Long examId, Long studentId);

    CourseExamPaperErrorSetStatsDTO statsData(CourseExamPaperErrorSetQueryDTO dto);

    /**
     * 根据试题id和错题类型查询错题集id ( questionId, id )
     */
    void findIdByQuestionIdsAndType(Long studentId, List<Long> questionIdList, PaperErrorSetTypeEnum tempType, Consumer<CourseExamPaperErrorSetEntity> s);
}
